﻿@model XZen.Blogger.Models.RestCall
@{
    ViewBag.Title = "Service";
    Layout = "~/Views/Shared/_ajaxLayout.cshtml";
}
<script src="http://localhost:44455/Rpc/easyXDM.debug.js" type="text/javascript"></script>
<script src="http://localhost:44455/Rpc/json2.js" type="text/javascript"></script>
<script src="http://localhost:44455/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
    var socket = new easyXDM.Socket({
        onMessage: function (message, origin) {
            var ob = JSON.parse(message);
            alert("Received '" + ob.token + "' from '" + origin + "'");
            ob.html += "Back from Server";
            //socket.postMessage(JSON.stringify(ob));
            CallAfterPost(ob, socket);
        }
    });
    function CallAfterPost(args, socket) {
        var url = args.url;      
        var data = (args.data) ? args.data: '';
        var method = (args.method) ? args.method : "GET";
        alert(url + " calling " + method);
        $.ajax({
            url: url,
           /* data: data, */
            type: method,
            success: function (d) {
                var ob = { result: d, args: args };
                socket.postMessage(JSON.stringify(ob));
            },
            error: function (b) {
                alert("Error.." + b);
            }
        });
    }
</script>
<div id="log" style="height: 100px; border: 1px dotted black; overflow: auto">
</div>

